FIX: execution and doc failures from the Anaconda 2026.07 cache build (closes #182)#183
Merged
Merged
Conversation
Resolves the four failures reported in #182. All four are target-side defects; the English source is healthy in every case. likelihood_bayes — the font block called `mpl.font_manager.fontManager` and `plt.rcParams` before `import matplotlib.pyplot as plt`. Newer matplotlib no longer imports `font_manager` as a side effect of `import matplotlib`, so this raised AttributeError (and would have raised NameError on `plt`). Moved the pyplot import above both uses. An audit of the font block across all 69 lectures found this the only file with either ordering hazard. kalman_2 — a `.text()` annotation drew the covariance matrix with `\begin{bmatrix}`, which matplotlib mathtext cannot render (it supports no LaTeX environments). Rewritten as `\left[ \substack{...} \right]`, which renders an equivalent bracketed 2x2 matrix under mathtext, using `\;` as the column separator rather than `&`. This keeps the drop-usetex standard from #22 intact with no loss of information. The lecture's other `\begin{bmatrix}` uses are inside `{math}` blocks, rendered by MathJax, and are unaffected. sir_model — the header directive had lost its argument: `{raw}` instead of `{raw} jupyter`. The other 50 lectures carrying this directive kept theirs. ak_aiyagari — the file carried a stray fence at line 38 followed by a duplicated copy of the original frontmatter, and a doubled closing fence at EOF. The stray opener ran to line 56, swallowing both the H1 title and the `_admonition/gpu.md` include, which is what produced the 13 "headings start at H2" warnings. Removed both strays; the file's fence structure now matches the English source exactly (122). The `translation.title` field was also corrupt ("V, σ, μ") and has been set to the lecture title. An edition-wide sweep found no other file with unbalanced fences. The last two are content corruption introduced in translation and warrant engine issues against action-translation; they are not covered by the existing #107/#115/#116/#117 set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
❌ Deploy Preview for astonishing-narwhal-a8fc64 failed.
|
❌ Deploy Preview for astonishing-narwhal-a8fc64 failed.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes four lecture-specific regressions in the zh-cn edition that caused execution and documentation build failures in the Anaconda 2026.07 cache build (per #182), without requiring upstream (English) backports.
Changes:
- Fixes a MyST
{raw}directive that was missing its requiredjupyterargument (sir_model). - Fixes Matplotlib import ordering so font setup can safely use
mpl.font_managerandplt.rcParams(likelihood_bayes). - Replaces an unsupported MathText LaTeX environment (
\begin{bmatrix}...\end{bmatrix}) with a MathText-compatible bracketed 2×2 matrix rendering (kalman_2). - Repairs corrupted fencing/frontmatter and corrects
translation.titlein the lecture header (ak_aiyagari).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lectures/sir_model.md | Restores the {raw} jupyter directive argument to fix a doc build error. |
| lectures/likelihood_bayes.md | Reorders Matplotlib imports so font configuration and plt.rcParams usage doesn’t fail at runtime. |
| lectures/kalman_2.md | Rewrites a covariance annotation to avoid unsupported MathText LaTeX environments. |
| lectures/ak_aiyagari.md | Removes stray/duplicated fences/frontmatter and fixes the corrupted translation.title field. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves the four failures reported in #182. All four are target-side defects — the English source is healthy in every case, so none of these is an upstream backport.
The four fixes
likelihood_bayes— execution break. The font block calledmpl.font_manager.fontManagerandplt.rcParamsbeforeimport matplotlib.pyplot as plt. Newer matplotlib no longer importsfont_manageras a side effect ofimport matplotlib, so this raisedAttributeError— and would have raisedNameErroronpltregardless. Moved the pyplot import above both uses. I audited the font block across all 69 lectures: this is the only file with either ordering hazard.kalman_2— execution break. A.text()annotation drew the covariance matrix with\begin{bmatrix}, which matplotlib mathtext cannot render — mathtext supports no LaTeX environments at all. Rewritten as\left[ \substack{...} \right]with\;as the column separator instead of&, which renders an equivalent bracketed 2×2 matrix and was verified by rendering it with real formatted values. This keeps the drop-usetex standard from #22 intact with no loss of information, so no exception to that standard is needed. The lecture's other\begin{bmatrix}uses are inside{math}blocks, rendered by MathJax in the browser, and were never at risk.Worth noting for future sweeps: this site is invisible to a naive grep, because the braces are
.format()-escaped as\begin{{bmatrix}}.sir_model— doc error. The header directive had lost its argument:```{raw}instead of```{raw} jupyter. The other 50 lectures carrying this directive kept theirs.ak_aiyagari— doc error, with a larger cause than #182 diagnosed. The issue recommended restoring a single H1. That would have papered over the actual bug. The file carried a stray fence immediately after the frontmatter, followed by a duplicated copy of the original frontmatter, plus a doubled closing fence at EOF. The stray opener ran to line 56, swallowing both the H1 title and the_admonition/gpu.mdinclude — which is what produced the 13 "headings start at H2" warnings. Restoring an H1 alone would have left the include broken.Removed both strays. The file's fence structure now matches the English source exactly (122 fences, balanced). The
translation.titlefield was also corrupt — it readV, σ, μ, which is a Python tuple-unpacking line from deep inside a code cell in the source — and has been set to the lecture title.Provenance
ak_aiyagari's corruption was introduced by the resync in #103. Before it (a664481) the file had 120 fences and was balanced; after (17b5b98) it had 124 with both strays present. The engine emitted its newtranslation:frontmatter, then an opening fence, then the entire original document verbatim, then a closing fence at EOF — it wrapped the document body in a code block. The corrupttranslation.titlepoints at the same root cause: the engine failed to parse this file's structure and fell back to a degraded path that mis-derived the title too.This warrants an engine issue against
action-translation; it is not covered by the existing #107/#115/#116/#117 set. Same for the{raw}argument stripping.Verification
code-cellcounts match the English source for all four files.kalman_2replacement was rendered with real formatted values to confirm it produces a correct bracketed matrix, rather than only checking that it parses (\substackwith&parses but renders the ampersand literally — that trap is why).What is not verified: none of this has been cold-executed. Per QuantEcon/meta#340 this repo's
ci.ymlsphinx-tojupyter step lacks-n -W, so a green build here is weak evidence for the two execution fixes. See the note below.On build parity — deliberately not in this PR
Comparing
ci.ymlagainst the source repolecture-python.mystconfirms meta#340 and widens it. The source's sphinx-tojupyter step runs-n -W --keep-going; this repo's runs with no flags. The source also has a "Clear stale Sphinx environment" step and execution-report artifact uploads for the notebook and LaTeX builds that this repo lacks, so when that step does fail here there is no traceback artifact to read.I have kept that out of this PR on purpose. Turning on
-n -Wwill surface every remaining latent failure in the edition at once — and there almost certainly are some, since the cache build that produced #182 reused old-environment cache for roughly 15 unchanged lectures that were never re-tested. Folding it in here would likely turn this PR red for reasons unrelated to its own fixes. Content first, then the safety flag as its own PR that is expected to surface more.Closes #182
🤖 Generated with Claude Code